<!DOCTYPE html>
<html lang="zh-CN"> <!-- 修改语言为中文 -->
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户注册</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 500px;
            margin: 0 auto;
            padding: 20px;
        }
        h1 {
            text-align: center;
            color: #333;
        }
        form {
            background-color: #f9f9f9;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        input[type="text"],
        input[type="password"],
        input[type="email"] {
            width: 100%;
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid #ccc;
            border-radius: 3px;
        }
        button {
            width: 100%;
            padding: 10px;
            background-color: #007BFF;
            color: #fff;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }
        button:hover {
            background-color: #0056b3;
        }
        .error {
            color: red;
            margin-top: 10px;
        }
    </style>
</head>
<body>
    <h1>用户注册</h1>
    <form action="/register" method="post" onsubmit="return validateForm()">
        <label for="username">用户名:</label>
        <input type="text" id="username" name="username" required 
               oninvalid="this.setCustomValidity('请输入用户名')" 
               oninput="this.setCustomValidity('')"><br>

        <label for="password">密码:</label>
        <input type="password" id="password" name="password" required 
               oninvalid="this.setCustomValidity('请输入密码')" 
               oninput="this.setCustomValidity('')"><br>

        <label for="email">邮箱:</label>
        <input type="email" id="email" name="email" required 
               oninvalid="this.setCustomValidity('请输入有效的邮箱地址')" 
               oninput="this.setCustomValidity('')"><br>

        <button type="submit">注册</button>
    </form>

    <!-- 显示消息 -->
    <div>
        <p th:text="${msg}" class="error"></p>
    </div>

    <script>
        function validateForm() {
            // 可以添加更多验证逻辑
            return true;
        }
    </script>
</body>
</html>
